﻿using FileTransfer.Client;
using FileTransfer.Client.Http.Client;
using FileTransferDesktop.Services;
using Microsoft.Extensions.DependencyInjection;
using ApiClient = FileTransfer.Client.ApiClient;

namespace FileTransferDesktop.Extensions;

public static class ServiceProviderExtensions
{
    public static ApiClient CreateApiClient(this System.IServiceProvider serviceProvider)
    {
        var config = serviceProvider.GetService<Configuration>();
        var service = serviceProvider.GetService<IAuthenticationService>()!;
        return ApiHelper.NewApiClient(config, () => service.Token);
    }
}
